package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 获取关联的id
     *
     * @param ids
     * @return
     */
    List<Long> getSetmealDishIds(List<Long> ids);

    /**
     * 新增数据
     *
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 删除每一个套餐里面的菜品
     *
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteById(Long setmealId);

    /**
     * 获取菜品
     *
     * @param id
     * @return
     */
    @Select("select setmeal_dish.*,category.id categoryId from setmeal_dish left join dish on dish.id=setmeal_dish.dish_id " +
            "left join category on category.id= dish.category_id where setmeal_dish.setmeal_id = #{id}")
    List<SetmealDish> getDishById(Long id);

    /**
     * 根据套餐id查询包含的菜品
     * @param id
     * @return
     */
    List<DishItemVO> getDishBySetmealId(Long id);
}
